﻿package  {
	import flash.display.*;
	import flash.events.*;
	import fl.transitions.Tween;
	import fl.transitions.easing.*;
	import fl.transitions.TweenEvent;
	import 	flash.geom.ColorTransform;

	public class moveableobj extends MovieClip {
	public var userdata:Number=-1;
	public var userdata2:Number=-1;
	 public var pposx:Number;
		public var pposy:Number;
		public var tpposx:Number;
		public var tpposy:Number;
		public var moviniv:Number;
		public var cvvv:Number;
		public var mstd:Number=0;
		public var inmstd:Number=0;
		public var clf:uint;
		public var clt:uint;
		public var clmv:Number;
		public var clmvc:Number;
		public function moveableobj() {
			// constructor code
		}
		public function alphafrom(f:Number,t:Number,mmv:Number)
		{
			var myTween:Tween = new Tween(this, "alpha", Back.easeIn, f, t, mmv, false);
		}
		public function colorfrom(f:uint,t:uint,mmv:Number)
		{
			clf=f;
			clt=t;
			if(mmv<1)mmv=1;
			clmv=mmv;
			clmvc=0;
			this.addEventListener( Event.ENTER_FRAME,inicolor); 
		}
		public function inicolor(e:Event)
		{
			 var colorInfo:ColorTransform;
     		 colorInfo = transform.colorTransform;
			 if(clmvc<=1)
			 {
      		colorInfo.color = clf+(clt-clf)*clmvc;
      		
			clmvc+=1.0/clmv;
      		transform.colorTransform = colorInfo;
			//trace(clmvc);
			//trace(colorInfo.color);
				//  trace(clt);
			 }
			 else
			 {
				 this.removeEventListener(Event.ENTER_FRAME,inicolor);
			 }
		}
		public function movefrom(xx:Number,yy:Number,mmv:Number)
		{
		//var myTween:Tween = new Tween(this, "x", Back.,xx, this.x, mmv, false);
		//var myTween2:Tween = new Tween(this, "y", Back.,yy, this.y, mmv, false);
		pposx=this.x;
		pposy=this.y;
		tpposx=xx;
		tpposy=yy;
		moviniv=mmv;
		cvvv=0;
		this.addEventListener( Event.ENTER_FRAME,inimove); 
		}
		public function inimove(e:Event)
		{
		if(inmstd==0 || inmstd>mstd)
		{
		if(cvvv<=moviniv)
		{
			moveto(tpposx+((pposx-tpposx)/moviniv)*cvvv,tpposy+((pposy-tpposy)/moviniv)*cvvv);
			
		}
			if(cvvv>=moviniv)
			{
				this.removeEventListener(Event.ENTER_FRAME,inimove);
			}
			cvvv++;
		}
		inmstd++;
		}
		public function moveto(xx:Number,yy:Number)
		{
			this.x=xx;
			this.y=yy;
		}
		public function getcenter():vector2
		{
			return new vector2(this.x+this.width/2,this.y+this.height/2);
		}

	}
	
}
